package dev.helper;

public class Convert {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int number=42;
		System.out.println(convert(number, 3));
	}

	public static String convert(int number,int radix){
		char[] buffer=new char[32];
		int i=1;
		int index=31;
		do{
			buffer[index--]=(char) ((number/i)%radix+48);
			i*=radix;
		}while(index>=0&&i<number);
		return String.copyValueOf(buffer, ++index, 32-index);
	}
}
